Is the following declaration correct?

int answer;

A good answer might be:

Yes—assuming that  answer  is a correct name for a variable.


Names for Variables

The programmer (you) picks a name for each variable in a program. There are several things in programs (including variables) that need to be named. Such a programmer-picked name is called an identifier. Here are the rules for choosing an identifier:

A reserved word is a word which has a predefined meaning in Java. For example int, double, true, and import are reserved words. Rather than worry about the complete list of reserved words, just remember to avoid using words that you know already mean something, and be prepared to make a change if you accidentally use one you didn't know.

QUESTION 6:

Which of the following variable declarations are correct?

long good-by ;

short shrift = 0;

double bubble = 0, toil= 9, trouble = 8

byte the bullet ;

int  double;

char thisMustBeTooLong ;

int 8ball;